home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 010 / blit.arc / MERGE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1985-05-23  |  1.8 KB  |  65 lines

  1. /*
  2.  * name:         merge
  3.  *
  4.  * description: merge sourceword with destinationword using the
  5.  *              boolean operation specified by the function code f.
  6.  *
  7.  * synopsis:     unsigned short  merge (sourceword, destinationword, f)
  8.  *              unsigned short   sourceword;
  9.  *              unsigned short   destinationword;
  10.  *              int      f;
  11.  *
  12.  * globals:      allones  (r)
  13.  *
  14.  * calls:        nothing.
  15.  *
  16.  * called by:    bitblt  (bitblt.c)
  17.  */
  18. #include "layers.h"
  19.  
  20. extern unsigned short  allones;
  21.  
  22. unsigned short merge (sourceword, destinationword, f)
  23. unsigned short sourceword;
  24. unsigned short destinationword;
  25. int    f;
  26. {
  27.  /*
  28.  * these are the 16 combination rules
  29.  */
  30.    switch (f) {
  31.        case all_zeros:
  32.            return (0);
  33.        case s_and_d:
  34.            return (sourceword & destinationword);
  35.        case s_and_nd:
  36.            return (sourceword & ~destinationword);
  37.         case s:
  38.            return (sourceword);
  39.        case ns_and_d:
  40.            return (~sourceword & destinationword);
  41.         case d:
  42.            return (destinationword);
  43.        case s_xor_d:
  44.            return (sourceword ^ destinationword);
  45.        case s_or_d:
  46.            return (sourceword | destinationword);
  47.        case ns_and_nd:
  48.            return (~sourceword & ~destinationword);
  49.        case ns_xor_d:
  50.            return (~sourceword ^ destinationword);
  51.        case nd:
  52.            return (~destinationword);
  53.        case s_or_nd:
  54.            return (sourceword | ~destinationword);
  55.        case ns:
  56.            return (~sourceword);
  57.        case ns_or_d:
  58.            return (~sourceword | destinationword);
  59.        case ns_or_nd:
  60.            return (~sourceword | ~destinationword);
  61.        case all_ones:
  62.            return (allones);
  63.    }
  64. }
  65.